import 'package:flutter/material.dart';

/// 无状态组件
class TapBoxB extends StatelessWidget {

  final bool active;

  final ValueChanged onChanged;

  const TapBoxB({Key key, this.active, this.onChanged}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print("TapBoxB build 被调用...");
    return GestureDetector(
      onTap: _handleTap,
      child: Container(
        child: Center(
          child: Text(
            active ? "Active" : "InActive",
            style: TextStyle(fontSize: 32.0, color: Colors.white),
          ),
        ),
        width: 200,
        height: 200,
        decoration: BoxDecoration(
          color: active?Colors.lightGreen[700]:Colors.grey[600],
        ),
      ),
    );
  }

  void _handleTap() {
    onChanged(!active);
  }
  
}
